//
//  MySubscribeCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/7/29.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "MySubscribeCell.h"

@implementation MySubscribeCell

- (void)awakeFromNib {
    [super awakeFromNib];

}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        [self.tagBGView pp_clipCorners:UIRectCornerBottomRight radius:12];
        [self.evaluateBtn pp_clipCorners:UIRectCornerAllCorners radius:self.evaluateBtn.frame.size.height/2];
    });
}

- (void)fillCellWithModel:(CommonSubscribeModel *)model {

    NSString *url = [TT_OSSManager reSourceUrl:model.seller.logoUrl type:BA_resizeType_plus];
    [self.storeIcon sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.storeName.text = model.seller.sellerName;
    self.storeAddress.text = model.seller.sellerAddress;
    
    self.timeLab.text = [NSString stringWithFormat:@"预约时间：%@",model.cdAppointmentTime];
    
    self.tagLab.text = model.parentName;
    
    self.evaluateBtn.hidden = YES;
    self.naviBtn.hidden = NO;
    self.imBtn.hidden = NO;
    self.phoneCallBtn.hidden = NO;
    
    switch (model.cdFollowUpStatus) {
        case 1:{
            self.statusLab.text = @"待处理";

        } break;
        case 2:{
            self.statusLab.text = @"跟进中";

        } break;
        case 3:{
            self.statusLab.text = @"预约成功";

        } break;
        case 4:{
            self.statusLab.text = @"已到店";
            
            if (model.isEvaluate==2) {//未评价的时候显示按钮
                
                self.evaluateBtn.hidden = NO;
                self.naviBtn.hidden = YES;
                self.imBtn.hidden = YES;
                self.phoneCallBtn.hidden = YES;
                
            } else {
                
            }
            
        } break;
        case 5:{
            self.statusLab.text = @"已完成";
        } break;
        default:
            break;
    }
    
}


- (IBAction)addressAction:(id)sender {
    
    if (self.MySubscribeCellBlock) {
        self.MySubscribeCellBlock(MySubscribeCellActionType_address);
    }
}

- (IBAction)imAction:(id)sender {
    if (self.MySubscribeCellBlock) {
        self.MySubscribeCellBlock(MySubscribeCellActionType_im);
    }
    
}

- (IBAction)callAction:(id)sender {
    if (self.MySubscribeCellBlock) {
        self.MySubscribeCellBlock(MySubscribeCellActionType_call);
    }
    
}

- (IBAction)evaluateAction:(id)sender {
    if (self.MySubscribeCellBlock) {
        self.MySubscribeCellBlock(MySubscribeCellActionType_evaluate);
    }
}

@end
